﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="AdminOrders.aspx.cs" Inherits="FlowersStore.AdminOrders" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <h2 class="AdminPart">
            Заказы</h2>
    </div>
    <div>
        <tt class="AdminSubPart">Заказы:</tt>
        <asp:DropDownList Style="margin-bottom: -6px;" ID="ddlStatus" runat="server" AutoPostBack="true"
            OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
            <asp:ListItem Text="Все" Value="0" Selected="True" />
            <asp:ListItem Text="Актуальные" Value="1" />
        </asp:DropDownList>
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="Order_id" DataSourceID="OrdersSqlDataSource">
            <EmptyDataTemplate>
                <table runat="server" style="">
                    <tr>
                        <td>
                            Заказов не поступало
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <AlternatingItemTemplate>
                <tr style="background-color: #FFF8DC; color: #000000;">
                    <td class="AdminTabCell">
                        <asp:Image runat="server" ID="imgStatus" ImageUrl='<%# GetStatusImageUrl(Eval("OrderStatus_id")) %>' ToolTip='<%# Eval("OrderStatus_name") %>'  />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_idLabel" runat="server" Text='<%# Eval("Order_id") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_DTLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_DT","{0:d} {0:t}") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_deliveryDTLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryDT","{0:d}")  %>' />
                        <br />
                        <asp:Label ID="Order_deliveryStartTimeLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryStartTime","{0:t}") %>' />
                        -
                        <asp:Label ID="Order_deliveryEndTimeLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryEndTime","{0:t}") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_addressLabel" runat="server" Text='<%# Eval("Order_address") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_totalPriceLabel" runat="server" Text='<%# Eval("Order_totalPrice") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:HyperLink ID="linkDetails" runat="server" NavigateUrl='<%# "~/OrderDetails.aspx?order="+Eval("Order_id") %>'
                            Text="Подробнее" />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <ItemTemplate>
                <tr style="background-color: #DCDCDC; color: #000000;">
                    <td class="AdminTabCell">
                        <asp:Image runat="server" ID="imgStatus" ImageUrl='<%# GetStatusImageUrl(Eval("OrderStatus_id")) %>' ToolTip='<%# Eval("OrderStatus_name") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_idLabel" runat="server" Text='<%# Eval("Order_id") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_DTLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_DT","{0:d} {0:t}") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_deliveryDTLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryDT","{0:d}")  %>' />
                        <br />
                        <asp:Label ID="Order_deliveryStartTimeLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryStartTime","{0:t}") %>' />
                        -
                        <asp:Label ID="Order_deliveryEndTimeLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Order_deliveryEndTime","{0:t}") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_addressLabel" runat="server" Text='<%# Eval("Order_address") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:Label ID="Order_totalPriceLabel" runat="server" Text='<%# Eval("Order_totalPrice") %>' />
                    </td>
                    <td class="AdminTabCell">
                        <asp:HyperLink ID="linkDetails" runat="server" NavigateUrl='<%# "~/OrderDetails.aspx?order="+Eval("Order_id") %>'
                            Text="Подробнее" />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server">
                    <tr runat="server">
                        <td runat="server">
                            <table id="itemPlaceholderContainer" runat="server" border="0" class="AdminTable">
                                <tr runat="server" style="">
                                    <th class="AdminTabTopLineCell" id="Th1" runat="server">
                                        Статус
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Номер заказа
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Время поступления
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Время исполнения
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Адрес доставки
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Cумма, руб.
                                    </th>
                                    <th class="AdminTabTopLineCell" id="Th2" runat="server">
                                        Подробности
                                    </th>
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" style=" text-align:center;">
                            <asp:DataPager ID="DataPager1" runat="server">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" FirstPageText="В начало"
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" LastPageText="В конец"
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="OrdersSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:FlowerStoreConnectionString %>"
            SelectCommand="SELECT [Order].*,OrderStatus_name FROM [Order] join OrderStatus on [Order].OrderStatus_id=OrderStatus.OrderStatus_id order by case when [Order].OrderStatus_id=2 then 0 when [Order].OrderStatus_id=1 then 1 else 2 end asc,Order_DT desc">
        </asp:SqlDataSource>
    </div>
</asp:Content>
